From 3e7f74c456996bb760031d3b66d5fd6c8665d2a9 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 23 May 2011 07:16:17 +0200 Subject: [PATCH] styleproperty: Change _css_value_to_string() Name it _gtk_style_property_print_value() and actually pass it the style property. This way, we can later change it to use custom print functions for different style properties. --- gtk/gtkcssprovider.c | 5 +---- gtk/gtkstyleproperty.c | 19 +++++++++++-------- gtk/gtkstylepropertyprivate.h | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 2b6e181e9e..5cb8d8b58f 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -2976,7 +2976,6 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset, GString *str) { GList *keys, *walk; - char *s; _gtk_css_selector_print (ruleset->selector, str); @@ -2996,9 +2995,7 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset, g_string_append (str, " "); g_string_append (str, prop->pspec->name); g_string_append (str, ": "); - s = _gtk_css_value_to_string (value); - g_string_append (str, s); - g_free (s); + _gtk_style_property_print_value (prop, value, str); g_string_append (str, ";\n"); } diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c index fc3c8dab23..3c4462367f 100644 --- a/gtk/gtkstyleproperty.c +++ b/gtk/gtkstyleproperty.c @@ -1403,8 +1403,10 @@ _gtk_css_value_parse (GValue *value, return (*func) (parser, base, value); } -char * -_gtk_css_value_to_string (const GValue *value) +void +_gtk_style_property_print_value (const GtkStyleProperty *property, + const GValue *value, + GString *string) { PrintFunc func; @@ -1416,14 +1418,15 @@ _gtk_css_value_to_string (const GValue *value) func = g_hash_table_lookup (print_funcs, GSIZE_TO_POINTER (g_type_fundamental (G_VALUE_TYPE (value)))); - if (func) + if (func == NULL) { - GString *string = g_string_new (NULL); - func (value, string); - return g_string_free (string, FALSE); + char *s = g_strdup_value_contents (value); + g_string_append (string, s); + g_free (s); + return; } - - return g_strdup_value_contents (value); + + func (value, string); } gboolean diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h index a1d222ecf5..8ffe0adf8b 100644 --- a/gtk/gtkstylepropertyprivate.h +++ b/gtk/gtkstylepropertyprivate.h @@ -59,7 +59,9 @@ void _gtk_style_property_pack (const GtkStyleProper gboolean _gtk_css_value_parse (GValue *value, GtkCssParser *parser, GFile *base); -char * _gtk_css_value_to_string (const GValue *value); +void _gtk_style_property_print_value (const GtkStyleProperty *property, + const GValue *value, + GString *string); G_END_DECLS -- 2.30.2